1
|
|
|
const e=require("./modules/multisort.js"),t=require("./modules/multifilter.js"),r=require("./modules/multikey.js"),s=require("./modules/intersect.js"),u=require("./modules/min.js"),i=require("./modules/max.js"),m=require("./modules/diff.js"),l=require("./modules/unique.js"),n=require("./modules/summ.js"),h=require("./modules/average.js"),o=require("./modules/random.js"),d=require("./modules/getByKey.js"),a=require("./modules/first.js"),g=require("./modules/last.js");class f extends Array{static get[Symbol.species](){return Array}multisort(t,r){return e(this[0],t,r)}multifilter(e,r,s){return t(this[0],e,r,s)}multikey(e){return r(this[0],e)}intersect(e,t){return s(this[0],e,t)}diff(e,t){return m(this[0],e,t)}get unique(){return l(this[0])}pushIfNotExists(e){return this.indexOf(e)<0&&this.push(e),this.length}pushMultiple(e){return this.push(...e),this.length}pushMultipleIfNotExists(e){const t=this;return e.forEach(e=>{t.pushIfNotExists(e)}),t.length}get max(){return i(this[0])}get min(){return u(this[0])}get random(){return o(this)}get summ(){return n(this[0])}get average(){return h(this[0])}getByKey(e,t){return d(this[0],e,t)}get first(){return a(this[0])}get last(){return g(this[0])}}module.exports={Arr:f,multisort:e,multifilter:t,multikey:r,intersect:s,min:u,max:i,diff:m,unique:l,summ:n,average:h,random:o,getByKey:d,first:a,last:g}; |
The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.
This operator is most often used in
for
statements.Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.
This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.
could just as well be written as:
To learn more about the sequence operator, please refer to the MDN.